package com.yanqu.road.server.su;

import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.TempServer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Objects;

public class ReloadManager {

	private static Logger logger = LogManager.getLogger(ReloadManager.class.getName());

	private TempServer tempServer;

	public ReloadManager(TempServer tempServer) {
		this.tempServer = tempServer;
	}

	public boolean reloadConfig(String mgrName) {
		try {
			for (TempMgr mgr : tempServer.getMgrList()) {
				if (Objects.equals(mgr.getClass().getSimpleName(), mgrName)) {
					mgr.reload();
					return true;
				}
			}
		} catch (Exception ex) {
			logger.error(ex);
		}

		return false;
	}
}
